package test;

import com.sun.concurrent.Account;
import com.sun.concurrent.AddMoneyThread;
import org.junit.Test;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * Created by sun on 2016/10/28.
 */
public class StringExample {
    @Test
    public void say() {
        String str1 = "abc";
        String str2 = "abc";
        System.out.println(str1.equals(str2));
        System.out.println();
        //钱啊
    }

    @Test
    public void hello() {
        Account account = new Account();
        ExecutorService service = Executors.newFixedThreadPool(100);

        for(int i = 1; i <= 100; i++) {
            service.execute(new AddMoneyThread(account, 1));
        }

        service.shutdown();

        while(!service.isTerminated()) {}

        System.out.println("账户余额: " + account.getBalance());
    }
}
